define([
        'underscore',
        'app/service/GeneralServices',
        'app/utils/WebUtils',
        'app/utils/UploadVideoThumbUtils',
        'app/utils/CommonUtils'
        ], function (
		_,
		GeneralServices,
		WebUtils,
		UploadVideoThumbUtils
    ) {
	
    var s = {};
	
	s.initDialog = function(roomuuid){
		$("#wjt_room_lecturepage_video_save").click(function(){
			
			var p ={
				id:$("#wjt_room_lecturepage_id_input").val(),
				pageurl:$("#wjt_room_lecturepage_video_input").val(),
				roomuuid:roomuuid
			}
			GeneralServices.room_lecturepage_video_save(p,function(resp){
				if(resp.status != "200"){
					WebUtils.alert("操作失败，请重试");
					return;
				}else{
					WebUtils.alert("保存成功");
					WebUtils.inputOriginalUpdate($("#wjt_room_lecturepage_video_input"));
				}
				var item = $("#room_lecturepage_"+resp.result.id);
				if(item.length == 0){
					$.setUrlParam("tab","3");
					return;
				}
				item.data("pageurl", resp.result.pageurl);
			});
		});
		
		
//		UploadVideoThumbUtils
		
	}
	
	s.open = function(id, pageurl, thumburl){
		
		WebUtils.inputInt($("#wjt_room_lecturepage_id_input"),id);
		WebUtils.inputInt($("#wjt_room_lecturepage_video_input"),pageurl);
		WebUtils.imageInt($("#wjt_room_lecturepage_video_preview"),thumburl);
		$("#wjt_room_lecturepage_video_dialog").modal();
		
		if($.isNullStr($("#wjt_room_lecturepage_id_input").val())){
			$(".wjt-room-lecturepage-video-thumb-area").hide();
		}else{
			$(".wjt-room-lecturepage-video-thumb-area").show();
		}
		
		
		var url = "/wjt/upload_lecture_video_thumb/"+$("#wjt_room_lecturepage_id_input").val();
		UploadVideoThumbUtils.initSingleImage("wjt_room_lecturepage_video_container","wjt_room_lecturepage_video_btn",url,
			function(up, file, info){
				console.log(up);
				console.log(file);
				console.log(info);
				var resp = JSON.parse(info.response);
				console.log(resp);
	
				//tab2 refresh...
				$.setUrlParam("tab","3");
				//"{"status":"200","result":{"path":"http://localhost:8014/attachment/img/ac3f7f1d-4462-4362-8363-8a08826ebe82","key":"ac3f7f1d-4462-4362-8363-8a08826ebe82"}}"
			});
	}
	
	return s;

});
